import axios from '@/libs/api.request'

// 菜单

// 左侧菜单
export const apiLeftMenuList = data => {
  return axios.request({
    url: '/auth/menus',
    method: 'get',
    data,
  })
}

// 菜单列表
export const apiMenuList = data => {
  return axios.request({
    url: '/admin/menu/tree',
    method: 'get',
    data,
  })
}

// 菜单添加
export const apiMenuAdd = data => {
  return axios.request({
    url: '/admin/menu',
    method: 'post',
    data,
  })
}

// 菜单删除
export const apiMenuDelete = id => {
  return axios.request({
    url: `/admin/menu/${id}`,
    method: 'delete',
  })
}

// 菜单更新
export const apiMenuUpdate = (id, data) => {
  return axios.request({
    url: `/admin/menu/${id}`,
    method: 'put',
    data,
  })
}
// 菜单详情
export const apiMenuDetail = id => {
  return axios.request({
    url: `/admin/menu/${id}`,
    method: 'get',
  })
}

// 管理员

// 管理员列表
export const apiAdminList = data => {
  return axios.request({
    url: '/admin/user',
    method: 'get',
    data,
  })
}

// 管理员添加
export const apiAdminAdd = data => {
  return axios.request({
    url: '/admin/user',
    method: 'post',
    data,
  })
}

// 管理员删除
export const apiAdminDelete = id => {
  return axios.request({
    url: `/admin/user/${id}`,
    method: 'delete',
  })
}

// 管理员更新
export const apiAdminUpdate = (id, data) => {
  return axios.request({
    url: `/admin/user/${id}`,
    method: 'put',
    data,
  })
}
// 管理员详情
export const apiAdminDetail = id => {
  return axios.request({
    url: `/admin/user/${id}`,
    method: 'get',
  })
}

// 机构信息
export const apiAdminUserCompany = data => {
  return axios.request({
    url: `/admin/usercompany`,
    method: 'get',
    data,
  })
}

// 角色

// 角色列表
export const apiRoleList = data => {
  return axios.request({
    url: '/admin/role',
    method: 'get',
    data,
  })
}

// 角色添加
export const apiRoleAdd = data => {
  return axios.request({
    url: '/admin/role',
    method: 'post',
    data,
  })
}

// 角色删除
export const apiRoleDelete = id => {
  return axios.request({
    url: `/admin/role/${id}`,
    method: 'delete',
  })
}

// 角色更新
export const apiRoleUpdate = (id, data) => {
  return axios.request({
    url: `/admin/role/${id}`,
    method: 'put',
    data,
  })
}
// 角色详情
export const apiRoleDetail = id => {
  return axios.request({
    url: `/admin/role/${id}`,
    method: 'get',
  })
}

// 机构菜单列表
export const apiAgencyMenuList = data => {
  return axios.request({
    url: '/agency/menu/tree',
    method: 'get',
    data,
  })
}

// 机构菜单添加
export const apiAgencyMenuAdd = data => {
  return axios.request({
    url: '/agency/menu',
    method: 'post',
    data,
  })
}

// 机构菜单删除
export const apiAgencyMenuDelete = id => {
  return axios.request({
    url: `/agency/menu/${id}`,
    method: 'delete',
  })
}

// 机构菜单更新
export const apiAgencyMenuUpdate = (id, data) => {
  return axios.request({
    url: `/agency/menu/${id}`,
    method: 'put',
    data,
  })
}
// 机构菜单详情
export const apiAgencyMenuDetail = id => {
  return axios.request({
    url: `/agency/menu/${id}`,
    method: 'get',
  })
}
